﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;
using System.Data;
using l1cs.server.datatables;
using l1cs.server.templates;

namespace l1cs.server.serverpackets
{
    public class S_BoardRead : ServerBasePacket
    {
        private static Logger _log = Logger.getLogger( typeof( S_BoardRead ).FullName );

        private byte[] _byte = null;

        public S_BoardRead( int number )
        {
            buildPacket( number );
        }

        private void buildPacket( int number )
        {
            L1Board board = BoardTable.getInstance().getBoard( number );

            writeC( Opcodes.S_OPCODE_BOARDREAD );
            writeD( number );
            writeS( board.name );
            writeS( board.date );
            writeS( board.title );
            writeS( board.content );

        }

        override
        public byte[] getContent()
        {
            if ( _byte == null )
            {
                _byte = getBytes();
            }
            return _byte;
        }

        override
        public String getType()
        {
            return "[C] S_BoardRead";
        }
    }
}
